
<template>
  <div class="goods-info" v-show="Object.keys(detailInfo).length">
    <div class="info-desc">
      <div class="start"></div>
      <p class="desc">{{detailInfo.desc}}</p>
      <div class="end"></div>
    </div>
    <div class="info-key">{{imgObj.key}}</div>
    <div class="info-list">
      <img :src="v" v-for="(v,i) in imgObj.list" :key='i' @load="imgLoad" />
    </div>
  </div>
</template>

<script>
export default {
  props: {
    detailInfo: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      imgObj: {},
      len: 0,
      count: 0
    }
  },
  methods: {
    imgLoad() {
      if (++this.count === this.len) {
        this.count = 0
        this.$emit('imgLoad')
      }
    }
  },
  watch: {
    detailInfo(val) {
      const data = val.detailImage
      this.imgObj = data[0]
      this.len = data[0].list.length
    }
  }
}
</script>

<style scoped>
.goods-info {
  padding: 20px 0;
  border-bottom: 5px solid #eee;
}
.info-desc {
  padding: 0 15px;
  font-size: 14px;
}
.desc {
  padding: 15px 0;
  color: #333;
}
.start,
.end {
  width: 130px;
  height: 1px;
  background-color: #999;
  position: relative;
}
.end {
  float: right;
}
.start::before,
.end::after {
  position: absolute;
  content: '';
  width: 5px;
  height: 5px;
  background-color: #333;
  bottom: 0;
}
.end::after {
  right: 0;
}
.info-key {
  font-size: 18px;
  margin: 10px 0 10px 15px;
}
.info-list img {
  width: 100%;
}
</style>
